package com.zoo.buyor.wechat.handler;


import com.zoo.buyor.wechat.service.WxMsgService;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class ScanHandler extends AbstractHandler {
    @Autowired
    WxMsgService wxMsgService;
    @Override
    public WxMpXmlOutMessage handle(WxMpXmlMessage wxMpXmlMessage, Map<String, Object> map,
                                    WxMpService wxMpService, WxSessionManager wxSessionManager) throws WxErrorException {
        // 扫码事件处理
        return wxMsgService.scanQRCodeWithArgument(wxMpXmlMessage);
//        String openId = wxMpXmlMessage.getFromUser();
//        String code = wxMpXmlMessage.getEventKey();
//        System.out.println(redirect_uri);
//        String grantUrl = String.format(URL, appId, redirect_uri);
//        return TextBuilder.build("请点击登录:<a href=\"" + grantUrl + "\">登录</a", wxMpXmlMessage);
    }
}
